import { useSelector,useDispatch } from "react-redux";
import { Link } from "react-router-dom";
export default function ReduxDemoCom() {

    const dispatch= useDispatch();

    let token=useSelector((state:any)=>state.token)
    let userInfo=useSelector((state:any)=>state.userInfo)

    const updateToken=()=>{

        dispatch({type:'UpdateToken',data:"888888888888"});
        
    }

    const updateUser=()=>{

        dispatch({type:'UpdateUserInfo',user:{name:"李四",age:20}});
    }
  return (
    <div>
      <div style={{ background: 'red',width:300,height:100 }}>
          {token}

          <div>
            {userInfo.name} {userInfo.age}
          </div>


 <button onClick={updateToken}>修改</button>
 <button onClick={updateUser}>修改UserInfo</button>

   <Link to={'/memo'}>跳转</Link>
      </div>
    </div>
  );
}